package com.liang.blog.reception.config;

import com.liang.blog.reception.controller.WebSocket;
import com.liang.blog.reception.service.BlogMsgInfoService;
import com.liang.blog.reception.service.BlogSessionListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 * @Author：YanWenLiang
 * @Date:2024-05-02-10:21
 */
@Configuration
public class WebSocketConfig {

    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

    //WebSocket中无法注入Bean,所以将其设置为静态的，在此注入

    @Autowired
    public void setMsgInfoService(BlogMsgInfoService msgInfoService){
        WebSocket.blogMsgInfoService = msgInfoService;
    }
    @Autowired
    public void setSessionListService(BlogSessionListService sessionListService){
        WebSocket.sessionListService = sessionListService;

    }
}
